package ntd.util.ai.action;

import ntd.util.ai.action.bo.AiActionBo;
import ntd.util.ai.action.impl.AiActionDefault;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class FactoryAction {

    private static final Map<String, AiActionBo> AI_ACTION_MAP = new HashMap<>();

    {
        register(new AiActionDefault());
    }

    /**
     * 注册Ai功能
     * @param aiAction
     */
    public static void register(AiAction aiAction) {
        AiActionBo info = aiAction.info();
        if (!AI_ACTION_MAP.containsKey(info.getCode())) {
            AI_ACTION_MAP.put(info.getCode(), info);
        }
    }

    /**
     * 获取Ai功能
     * @param code
     * @return
     */
    public static AiActionBo get(String code) {
        return AI_ACTION_MAP.get(code);
    }

    /**
     * 获取Ai功能列表
     * @return
     */
    public static Collection<AiActionBo> list() {
        return AI_ACTION_MAP.values();
    }
}
